/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package json;

import flexjson.JSONSerializer;

/**
 *
 * @author WangShuai
 */
public class TestJson {
    public static void main(String[] args) {
//        ReturnObject ro = new ReturnObject();
//        ro.put("name", "tom");
//        System.out.println(ro.toJSON());
        Person person = new Person();
        person.setId(1);
        person.setName("Magic");
        person.setPassword("123456");
        person.put("addr", "China");
        JSONSerializer serializer = new JSONSerializer();
        //如果有父类，则默认只序列化父类的属性
        System.out.println(serializer.serialize(person));
        System.out.println(serializer.serialize("Person", person)); //Add root name
        System.out.println(person.toJSON());
        //同时使用JSONObject将子类的属性加入到JSON中
        System.out.println(person.toJSONIncludeSub());
    }
}
